package cn.yuyiling.jelly.qa.mongodb.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Document(collection = "answer")
@Data
@NoArgsConstructor
public class Answer implements Serializable {
    @Id
    private String id;

    private String type = "answer";

    @Field("parent_id")
    private String parentId;

    private String path;

    private int depth = 1;

    @Field("knowledge_points")
    private List<String> knowledgePoints;

    @Field("author_id")
    private String authorId;

    @Field("created_at")
    private Date createdAt;

    @Field("updated_at")
    private Date updatedAt;

    private Content content;

    private int likes = 0;

    private int dislikes = 0;

    private Metadata metadata;

    @Data
    @NoArgsConstructor
    public static class Content implements Serializable {
        private String text;
        private String format;
        private List<Attachment> attachments;
    }

    @Data
    @NoArgsConstructor
    public static class Attachment implements Serializable {
        private String type;
        private String url;
        private String caption;
    }

    @Data
    @NoArgsConstructor
    public static class Metadata implements Serializable {
        @Field("ai_evaluation")
        private int aiEvaluation;

        private boolean flagged;
        private List<String> tags;
        private String visibility;
    }
}